"""
基于pd.Series的  技术分析指标
参数说明
s: pd.Series
m,n,p: int
返回：
大写函数，返回  pd.Series
小写函数，返回 最后一个值
"""
import pandas as pd


def Max(s1: pd.Series, s2: pd.Series):
    df = pd.DataFrame()
    df['s1'] = s1
    df['s2'] = s2
    return df.max(axis=1)


def Min(s1: pd.Series, s2: pd.Series):
    df = pd.DataFrame()
    df['s1'] = s1
    df['s2'] = s2
    return df.min(axis=1)


def TNR(s: pd.Series, m=10, n=3):
    """Trend to Noise Ratio"""
    dm = s.diff(m).abs()
    dm1 = s.diff(1).abs()
    sdm = dm1.rolling(n).mean()
    return dm / sdm
